//
//  GetDeviceInfoNormalTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/7/22.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "GetDeviceInfoNormalTableViewCell.h"
#import "BMLineView.h"

@interface GetDeviceInfoNormalTableViewCell ()
@property (nonatomic, strong) BMLineView *lineView;
@end
@implementation GetDeviceInfoNormalTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];
    BMLineView *lineView = [BMLineView lineViewWithFrame:CGRectZero];
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(DeviceInfoModel *)model {
    _model = model;
    
    if (model.showType == 1) {
        self.contentLabel.text = model.status == 1 ? @"在线":@"离线";
        self.contentLabel.textColor = model.status == 1 ? RGB(65, 206, 231) : RGB(154, 154, 154);
        self.timeLabel.hidden = YES;
    }
    else {
        self.contentLabel.text = model.username;
        self.contentLabel.textColor = RGB(154, 154, 154);
        self.timeLabel.text = [BMUtils formatTimeWithServiceTime:model.reg_time];
        self.timeLabel.hidden = NO;
    }
    
    self.titleLabel.text = model.device_name;
    self.iconView.image = model.image;
}

- (void)setUserModel:(DeviceUserInfoModel *)userModel {
    _userModel = userModel;
    self.titleLabel.text = userModel.username?:@"";
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:userModel.logo_url] placeholderImage:[UIImage imageNamed:@"app_user_default_portrait_ic"]];
    self.contentLabel.text = userModel.mobile?:@"";
    self.timeLabel.hidden = YES;
    self.iconView.layer.cornerRadius = 22.5f;
    self.iconView.layer.masksToBounds = YES;
}

@end
